using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;

namespace DigitalTrainSuite.UserControls
{
	public enum SignalState { GREEN, YELLOW, RED, GO = GREEN, SLOW = YELLOW, STOP = RED };

	public delegate void SignalStateChanged(int id, SignalState state);

	public partial class UserControlSignalController : UserControl
	{
		public event SignalStateChanged signalStateChanged;

		private int id;

		public int Id
		{
			get { return id;}
			set { id = value;}
		}
	
		public UserControlSignalController()
		{
			InitializeComponent();
		}

		private void radioButtonRed_CheckedChanged(object sender, EventArgs e)
		{
			if (this.radioButtonRed.Checked && this.signalStateChanged != null)
			{
				this.signalStateChanged(this.Id, SignalState.RED);
			}
		}

		private void radioButtonYellow_CheckedChanged(object sender, EventArgs e)
		{
			if (this.radioButtonYellow.Checked && this.signalStateChanged != null)
			{
				this.signalStateChanged(this.Id, SignalState.YELLOW);
			}
		}

		private void radioButtonGreen_CheckedChanged(object sender, EventArgs e)
		{
			if (this.radioButtonGreen.Checked && this.signalStateChanged != null)
			{
				this.signalStateChanged(this.Id, SignalState.GREEN);
			}
		}
	}
}
